#!/bin/sh
# Created on 20100623 by Jimmy Wu
# Prints to stdout the rows of file $1 that correspond to the rows
# with a 1 read from stdin
#
# Arguments:
#   $1: intersections
# Standard input:
#   binary column indicating which rows to select
# Standard output:
#   selected rows from $1

usage() {
    echo "Usage: $(basename $0) intersections_file < binary_column_stdin"
}

if [ $# -lt 1 ] ; then
    usage >&2
    exit 1;
fi

intersections="$1"

paste - "$intersections" | grep '^1' | cut --complement -f1
